class re{
    constructor(){
        this.url = "http://localhost:3000/api"
        // this.ri = document.querySelector(".fl_ri")
        this.ri = document.querySelectorAll(".fl_ri")
        console.log(this.ri)
        this.load()
    }
    load(){
        ajax({
            url:this.url,
            data:{
                type:"getGoods"
            },
            success:res=>{
                this.res=JSON.parse(res).msg
                this.render()
            }
        })
    }
    render(){
        let str = ""
        this.res.forEach(val=>{
            str+=`<a href="#"><div class="box" index="${val.proId}">   
                    <div class="pic">
                        <img src="${val.img}" alt="">
                    </div>
                    <div class="info">
                        <p class="name">${val.proName}</p>
                        <p class="sales">已售：${val.sales}件<span class="minnum">起批量：${val.minnum}</span></p>
                        <p class="price">建议零售价：￥${val.price}</p>
                    </div>
                </div></a>`
        })
        // this.ri.innerHTML = str
        this.ri[0].innerHTML = str
        this.ri[1].innerHTML = str
        this.ri[2].innerHTML = str
        this.ri[3].innerHTML = str
        this.ri[4].innerHTML = str
        this.ri[5].innerHTML = str
    }
}
new re()